//
// Project: Disagreement in science: Missing women



clear all
version 15.1  



//
// set locals





//
// AER PREVIOUS PUBS FROM ALL AEA JOURNALS

// call data
use "${data}/output/aer_data_gender.dta", clear
drop if month=="May" & year!=2019  // exclude AEA papers and proceedings
drop if year==2020  
keep if (comment | research_article)
append using "${data}/output/all_aea_data_nogender.dta"  // include observations from all AEA journals to capture seniority
keep if journal=="American Economic Review" | type=="JOURNAL ARTICLE" | type=="PAPERS" | type=="REGULAR ARTICLE" | type=="REGULAR ARTICLES" | type=="Regular papers" | type=="SHORTER PAPERS"
drop if journal=="Journal of Economic Literature"

// generate cumulative total number publications by author and indicator of author in JEL
bysort full_name (article_id_chronological): generate previous_pubs = _n

append using "${data}/output/all_aea_data_nogender.dta"  // include observations from all AEA journals to capture seniority
keep if journal=="American Economic Review" | journal=="Journal of Economic Literature"
generate jel = journal=="Journal of Economic Literature"
bysort full_name: egen jel_author = max(jel)
keep if journal=="American Economic Review"  // observations from the AER
bysort full_name: egen double max_cumul_pubs = max(previous_pubs)
bysort full_name: keep if previous_pubs==max_cumul_pubs
*replace previous_pubs = 5 if previous_pubs>5 & previous_pubs<.

// analysis
local i=1
local coefficients`i' "2"
regress previous_pubs i.jel_author i.year, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}



//
// significance stars for regressions above
forvalues j=1/1 {
	foreach k of numlist `coefficients`j'' {
		if `p`j'_`k''<0.1 & `p`j'_`k''>=0.05 {
			scalar st`j'_`k'="*"
		}
		else if `p`j'_`k''<0.05 & `p`j'_`k''>=0.01 {
			scalar st`j'_`k'="**"
		}
		else if `p`j'_`k''<0.01 & `p`j'_`k''>=0.001 {
			scalar st`j'_`k'="***"
		}
		else if `p`j'_`k''<0.001 {
			scalar st`j'_`k'="****"
		}
		else {
			scalar st`j'_`k'=""
		}
	}
}

